import _ from 'lodash'
import Vue from 'vue';

/**
 * 全局 mutations
 */
const mutations = {

    /**
     * 添加 Tab
     * @param param0 Tabs
     * @param tab 
     */
    addTab({ tabs }, tab: any) {
        tabs.push(tab)
    },

    /**
     * 关闭 Tab
     * @param param0 Tabs
     * @param tabName
     */
    closeTab({tabs}, tabName: any) {
        let index = _.findIndex(tabs, function(tab: any) {
            return tab.name === tabName
        })
        Vue.delete(tabs, index)
    },
    setPolicy(state: any, res: any) {
        state.policy = res
    },
    setUserForInit(state: any) {
        state.userInfo = JSON.parse(localStorage.getItem('userInfo'));
    },
    setAllTips(state: any, allTips: any){
        state.allTips = allTips;
    }
}

export default mutations